<?php
use app\models\Mall;
use app\models\MallFrontEnd;
use yii\helpers\Url;

$institution_code = Mall::getCurrentInstitutionCode();
$user = Mall::getCurrentUser();
$isLogin=false;;
if ($user != null) {
    $isLogin=true;
    ?>
    <script>
        $(function($){
            refreshToolBarBottomGetCartGoodsCount();
        });
    </script>
<?php
}
?>
<script>
    function refreshToolBarBottomGetCartGoodsCount(){
        requestJson('get-cart-goods-count',null,true,function(re){
            if(re.status==0){
                if(re.data=='0'){
                    $('.shop-car .shop-car-number').hide();
                }else{
                    $('.shop-car .shop-car-number').show();
                    $('.shop-car .shop-car-number').html(re.data);
                }

            }
        });
    }
</script>
<div class="tab-frame">
    <a class="tab-item <?=$actionName=='index' ? 'tab-item-selected' : ''?>" href="<?=Url::to(['mall-m/index',  'institution_code' => $institution_code]) ?>">
        <div class="icon icon-home"></div>
        <label>首页</label>
    </a>
    <a class="tab-item <?=$actionName=='category' ? 'tab-item-selected' : ''?>" href="<?=Url::to(['mall-m/category',  'institution_code' => $institution_code]) ?>">
        <div class="icon icon-category"></div>
        <label>分类</label>
    </a>
    <?php
        if($isLogin){
    ?>
        <a class="tab-item shop-car <?=$actionName=='cart' ? 'tab-item-selected' : ''?>" href="<?=Url::to(['mall-m/cart',  'institution_code' => $institution_code]) ?>">
            <div class="icon icon-cart"></div>
            <label>购物车</label>
            <p class="shop-car-number" style="display: none;">0</p>
        </a>
    <?php
        }else{
    ?>
        <a class="tab-item <?=$actionName=='cart' ? 'tab-item-selected' : ''?>" href="<?=Url::to(['mall-m/cart',  'institution_code' => $institution_code]) ?>">
            <div class="icon icon-cart"></div>
            <label>购物车</label>
        </a>
    <?php
        }
    ?>

    <a class="tab-item <?=$actionName=='user' ? 'tab-item-selected' : ''?>" href="<?=Url::to(['mall-m/user-center',  'institution_code' => $institution_code]) ?>">
        <div class="icon icon-user"></div>
        <label>我的</label>
    </a>
</div>